package com.ruoyi.wbs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wbs.domain.ProjectActivity;
import com.ruoyi.wbs.service.IProjectActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目活动Controller
 * 
 * @author renyuxin
 * @date 2024-06-11
 */
@RestController
@RequestMapping("/wbs/projectActivity")
public class ProjectActivityController extends BaseController
{
    @Autowired
    private IProjectActivityService projectActivityService;

    /**
     * 查询项目活动列表
     */
    @PreAuthorize("@ss.hasPermi('wbs:projectActivity:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectActivity projectActivity)
    {
        startPage();
        List<ProjectActivity> list = projectActivityService.selectProjectActivityList(projectActivity);
        return getDataTable(list);
    }

    /**
     * 导出项目活动列表
     */
    @PreAuthorize("@ss.hasPermi('wbs:projectActivity:export')")
    @Log(title = "项目活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectActivity projectActivity)
    {
        List<ProjectActivity> list = projectActivityService.selectProjectActivityList(projectActivity);
        ExcelUtil<ProjectActivity> util = new ExcelUtil<ProjectActivity>(ProjectActivity.class);
        util.exportExcel(response, list, "项目活动数据");
    }

    /**
     * 获取项目活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('wbs:projectActivity:query')")
    @GetMapping(value = "/{avtivityId}")
    public AjaxResult getInfo(@PathVariable("avtivityId") Long avtivityId)
    {
        return success(projectActivityService.selectProjectActivityByAvtivityId(avtivityId));
    }

    /**
     * 新增项目活动
     */
    @PreAuthorize("@ss.hasPermi('wbs:projectActivity:add')")
    @Log(title = "项目活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectActivity projectActivity)
    {
        return toAjax(projectActivityService.insertProjectActivity(projectActivity));
    }

    /**
     * 修改项目活动
     */
    @PreAuthorize("@ss.hasPermi('wbs:projectActivity:edit')")
    @Log(title = "项目活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectActivity projectActivity)
    {
        return toAjax(projectActivityService.updateProjectActivity(projectActivity));
    }

    /**
     * 删除项目活动
     */
    @PreAuthorize("@ss.hasPermi('wbs:projectActivity:remove')")
    @Log(title = "项目活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{avtivityIds}")
    public AjaxResult remove(@PathVariable Long[] avtivityIds)
    {
        return toAjax(projectActivityService.deleteProjectActivityByAvtivityIds(avtivityIds));
    }
}
